package com.chuhe.starry.controller;

import com.chuhe.common.domain.entity.UserInfo;
import com.chuhe.common.domain.query.PaginationResultVO;
import com.chuhe.common.domain.vo.req.AdminLoadUserReq;
import com.chuhe.common.domain.vo.resp.ApiResult;
import com.chuhe.starry.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * 用户管理
 * @Author: 楚河
 * @Date: 2025-05-18 10:26
 */
@RestController()
@RequestMapping("/admin")
@Api(value = "用户管理接口", tags = "用户管理相关API", description = "用户管理API")
public class AdminUserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping("/loadUser")
    @ApiOperation("用户管理")
    public ApiResult<PaginationResultVO<UserInfo>> loadUser(AdminLoadUserReq req){
        return ApiResult.success(userInfoService.findListByPage(req));
    }

    @RequestMapping("/updateUserStatus")
    @ApiOperation("修改用户在线状态")
    public ApiResult<?> updateUserStatus(@NotNull Integer status, @NotEmpty String userId){
        userInfoService.updateUserStatus(status,userId);
        return ApiResult.success(null);
    }

    @RequestMapping("/forceOffLine")
    @ApiOperation("强制下线")
    public ApiResult<?> forceOffLine(@NotEmpty String userId){
        //todo 强制下线
        userInfoService.forceOffLine(userId);
        return ApiResult.success(null);
    }
}
